package com.games.hanged;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HangedImageServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		//Set the mime type of the image
        resp.setContentType("image/jpeg");

        try{
            BufferedImage bufferedImage = new BufferedImage(400, 430, 
                         BufferedImage.TYPE_INT_RGB);

            Graphics g = bufferedImage.getGraphics();
	        g.setColor(Color.white);
	        g.fillRect(7,150,385,224);
	        g.setColor(Color.black);
	        g.fillRect(90,180,20,190);
	        g.setColor(Color.black);
	        g.fillRect(90,160,190,20);
	        g.setColor(Color.gray);
	        g.fillRect(250,180,5,20);
            
            ImageIO.write(bufferedImage, "jpg", resp.getOutputStream());
        
        }catch (IOException ioe){}
	}
	
	
}
